package com.rmb.userinfo.controller;

import com.rmb.common.model.response.CommonCode;
import com.rmb.common.model.response.QueryResponseResult;
import com.rmb.common.model.response.ResponseResult;
import com.rmb.mart.entity.log.LogAddress;
import com.rmb.userinfo.service.LogAddressService;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 段段
 * @PackageName: com.rmb.userinfo.controller
 * @ClassName: LogAddressController
 * @Description: (操作日志)表控制层
 * @data: 2021/1/20 15:18
 **/
@RestController
@RequestMapping("logAddress")
public class LogAddressController {
    /**
     * 服务对象
     */
    @Resource
    private LogAddressService logAddressService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public LogAddress selectOne(Long id) {
        return this.logAddressService.queryById(id);
    }

    /**
     * 插叙内所有操作数据
     */
    @GetMapping("/selectAll")
    public QueryResponseResult selectAll(){
        List list = logAddressService.selectAll();
        return new QueryResponseResult(CommonCode.QUERY_SUCCESS,list);
    }

    /**
     * 导出Excal表
     */
    @GetMapping("/exportExcal")
    public ResponseResult exportExcal(){
        boolean flag = logAddressService.exportExcal();
        return flag ? new ResponseResult(CommonCode.SUCCESS) :
                new ResponseResult(CommonCode.FAIL);
    }

}